package app.netant.finishbook.laiqi;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
/**
 * 
 * @author JiaJ
 *
 */
public class LaiqiDetail extends BaseDetail {

	public LaiqiDetail(String netSite) {
		super(netSite);
		this.preHref = "http://www.laiqi.net";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select(".g-bdw .g-bd .g-bdc .g-mn .g-mnc .m-focuswrap .m-rightinfo .m-bookinfo h2 em");
		if(parts.size()>0){
			String title = parts.get(0).text();
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".txt");
		}
	}

	@Override
	public void analyseTags() {
		Elements parts = this.select(".g-bdw .g-bd .g-bdc .g-mn .g-mnc .m-focuswrap .m-rightinfo .m-bookinfo p span");
		for(int i=0;i<parts.size();i++){
			String tag = parts.get(i).text();
			int idx = tag.indexOf("：");
			if(idx>0){
				String tagName = this.getString(tag.substring(0,idx)).trim();
				String tagValue = this.getString(tag.substring(idx+1)).trim();
				System.out.println("【Tag】:"+tagName+"="+tagValue);
				this.entity.setTag(tagName, tagValue);
			}
		}
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select(".g-bdw .g-bd .g-bdc .g-mn .g-mnc .m-introbox .m-intro .txt");
		if(parts.size()>0){
			String memo = this.getString(parts.get(0).text());
			System.out.println("【Memo】:"+memo);
			this.entity.setNovelMemo(memo);
		}
	}

	@Override
	public void analyseHref() {
		Elements parts = this.select(".g-bdw .g-bd .g-bdc .g-mn .g-mnc .m-focuswrap .m-rightinfo .m-ops .btn a");
		if(parts.size()>1){
			String href = parts.get(1).attr("href");
			if(href.startsWith("/")){
				href = this.preHref + href;
			}
			System.out.println("【Href】:"+href);
			this.entity.setDownPath(href);
		}
	}
	
	@Override
	public void analyseType() {
		
	}
	
	public static void main(String[] args) {
		LaiqiDetail detail = new LaiqiDetail("http://www.laiqi.net/shu/16700.html");
		detail.test();
	}



}
